<template>
  <div class="lottery-wrap">
    <div class="lottery-box" v-for="(item,index) in lotteryList" :key="index" v-if="lotteryList.length>0"
         @click="toPage(item.activityImage)">
      <img :src="item.activityUrl" class="pic" onclick="return false"/>
    </div>

    <back-page @backPage="back"></back-page>
  </div>
</template>

<script>
  import {baseUrl} from "../../../common/js/env"
  import backPage from "../../../components/backpage"

  export default {
    data() {
      return {
        userSign: "",
        lotteryList: []
      }
    },
    mounted() {
      let base64 = require('js-base64').Base64;
      this.userSign = base64.decode(sessionStorage.getItem("user_sign"));
      this.queryLotteryList();
    },
    methods: {
      queryLotteryList() {
        this.$vux.loading.show({
          text: '加载中',
        });
        this.axios.get(baseUrl + "/activity/get_activity_list?type=1").then((res) => {//获取活动列表
          let resultObj = res.data;
          this.$vux.loading.hide();
          if (resultObj.code == 0 && resultObj.data != null) {
            this.lotteryList = resultObj.data;
          } else {
            this.$vux.toast.text(resultObj.msg, "middle");
            return;
          }
        }).catch(() => {
          this.$vux.loading.hide();
          this.$vux.toast.text("网络异常", "middle");
        });
      },
      toPage(path) {
        let way = path.split("#")[1];
        this.$router.push({path: way, query: {"id": this.userSign}});
      },
      back() {
        this.$router.push('/mine');
      }
    },
    components: {
      backPage
    }
  }
</script>

<style lang="stylus" scoped>
  .lottery-wrap
    width: 100%
    height: auto
    overflow: hidden
    .lottery-box
      margin: 0 auto
      width: 92.53%
      height: 3.493rem
      margin-top: 0.253rem
      .pic
        width: 100%
        height: 100%
        border-radius: 0.08rem
</style>
